package com.hamizhong.iflowers.web.action.admin.statics;

import net.sf.json.JSONObject;

import com.hamizhong.iflowers.service.ITargetService;
import com.hamizhong.iflowers.utils.MyConstants;
import com.hamizhong.iflowers.web.base.MyBaseAjaxAction;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.IObjectVO;
import com.hamizhong.iflowers.web.vo.TargetVO;

public class AjaxDeleteTargetAction extends MyBaseAjaxAction {
	
	private ITargetService iTargetService = null;
	
	public ITargetService getiTargetService() {
		return iTargetService;
	}
	public void setiTargetService(ITargetService iTargetService) {
		this.iTargetService = iTargetService;
	}
	
	@Override
	protected JSONObject doRequest() {
		logger.info("...invoke...AjaxDeleteTargetAction...");
		String targetId = getRQ().getParameter("targetId");
		IOPResultDto<IObjectVO> resultDto = new IOPResultDto<IObjectVO>();
		TargetVO targetVO = new TargetVO();
		targetVO.setTargetId(targetId);
		resultDto = iTargetService.deleteTarget(targetVO);
		JSONObject jo = new JSONObject();
		if(resultDto.isSuccess()) {
			jo.put("result", MyConstants.AJAX_SUCCESS);
		}else {
			jo.put("result", MyConstants.AJAX_FAILED_ALERT);
			jo.put("msg", resultDto.getErrorMSG());
		}
		return jo;
	}

}
